package com.fyzk.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tyjc.lottery.R;


/**
 * 界面底部view
 * 
 * @author fxs
 *
 */
public class BottomView extends RelativeLayout implements OnClickListener{
	
	private Context context;
	private TextView tv_right;
	private TextView tv_left;
	
	private LinearLayout ll_ziDingYi;
	private LinearLayout ll_moRen;
	private TextView tv_moRen1;
	private TextView tv_moRen2;
	
	private onBottomClickListener listener;

	public BottomView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.context = context;
		init();
	}
	

	public BottomView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		init();
	}

	public BottomView(Context context) {
		super(context);
		this.context = context;
		init();
	}
	
	/**初始化View*/
	private void init(){
		View.inflate(context, R.layout.dj_layout_bottom, this);
		
		tv_right = (TextView) findViewById(R.id.dj_bottom_tv_right);
		tv_left = (TextView) findViewById(R.id.dj_bottom_tv_left);
		
		ll_ziDingYi = (LinearLayout) findViewById(R.id.dj_bottom_zidingyi_ll);
		ll_moRen = (LinearLayout) findViewById(R.id.dj_bottom_moren_ll);
		tv_moRen1 = (TextView) findViewById(R.id.dj_bottom_moren_tv1);
		tv_moRen2 = (TextView) findViewById(R.id.dj_bottom_moren_tv2);
		
		tv_right.setOnClickListener(this);
		tv_left.setOnClickListener(this);
	}
	
	public interface onBottomClickListener{
		void onBottomLeftClick();
		void onBottomRightClick();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.dj_bottom_tv_left:
			if(null!=listener){
				listener.onBottomLeftClick();
			}
			break;
		case R.id.dj_bottom_tv_right:
			if(null!=listener){
				listener.onBottomRightClick();
			}
			break;

		default:
			break;
		}
		
	}



	public void setonBottomClickListener(onBottomClickListener listener) {
		this.listener = listener;
	}
	
	//========= 中间		=============
	public void addCenterZiDingYiView(View view){
		ll_ziDingYi.setVisibility(View.VISIBLE);
		ll_ziDingYi.addView(view);
	}
	
	public void setMoRenVisibility(int type){
		ll_moRen.setVisibility(type);
	}
	
	public void setMoRenText1(String text){
		tv_moRen1.setText(text);
	}
	
	public void setMoRenText1(int text){
		tv_moRen1.setText(text);
	}
	
	public void setMoRenText2(String text){
		tv_moRen2.setText(text);
	}
	
	public void setMoRenText2(int text){
		tv_moRen2.setText(text);
	}
	
	public void setMoRen1_textColor(int color){
		tv_moRen1.setTextColor(color);
	}
	
	public void setMoRen2_textColor(int color){
		tv_moRen2.setTextColor(color);
	}
	
	//========= 左侧按钮	=============
	public void setLeftVisibility(int type){
		tv_left.setVisibility(type);
	}
	
	public void setLeftBackground(int resid){
		tv_left.setBackgroundResource(resid);
	}
	
	public void setLeftText(String text){
		tv_left.setText(text);
	}
	
	public void setLeftText(int text){
		tv_left.setText(text);
	}
	
	//========= 右侧按钮	=============
	public void setRightVisibility(int type){
		tv_right.setVisibility(type);
	}
	
	public void setRightBackground(int resid){
		tv_right.setBackgroundResource(resid);
	}
	
	public void setRightText(String text){
		tv_right.setText(text);
	}
	
	public void setRightText(int text){
		tv_right.setText(text);
	}

}
